﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using GalleryCommon;

namespace GalleryWeb
{
    public partial class PictureView : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string v = Request.QueryString["PicID"];
            if (v != null)
            {
                Picture pic;
                GalleryLogic.PictureLogic.ProvidePictureByID(Convert.ToInt64(v), out pic);
                TablePicture.Rows.Clear();
                HtmlTableRow row = new HtmlTableRow();
                HtmlTableCell cell = new HtmlTableCell();
                HtmlImage img = new HtmlImage();
                try
                {
                    img.Src = "data:image/png;base64," + Convert.ToBase64String(pic.PictureFile);
                    img.Attributes.Add("width", "100%");
                    cell.Controls.Add(img);
                    row.Cells.Add(cell);

                }
                catch { }
                TablePicture.Rows.Add(row);
            }

        }
    }
}